<?php

namespace Lambq\Mqtt;

use Illuminate\Support\ServiceProvider;
use Lambq\Mqtt\MqttClass\Mqtt;

class MqttServiceProvider extends ServiceProvider
{
    protected $commands = [
        Console\InstallCommand::class,
        Console\createTaskCommand::class,
    ];
    public function boot()
    {
        $this->mergeConfigFrom(__DIR__.'/config/mqtt.php','mqtt');
        $this->registerPublishing();
    }

    public function register()
    {
        $this->app->singleton('Mqtt',function (){

            return new Mqtt();
        });
        $this->commands($this->commands);
    }

    /**
     * @return array
     */
    public function provides()
    {
        return array('Mqtt');
    }

    /**
     * 资源发布注册.
     *
     * @return void
     */
    protected function registerPublishing()
    {
        if ($this->app->runningInConsole()) {
            $this->publishes([__DIR__.'/config/mqtt.php' => config_path('mqtt.php'), 'lambq-mqtt-config']);
        }
    }
}
